﻿using System;
using System.Data;
using Model;
using DBUtility;

namespace DAL
{
     /// <summary>
     /// 数据访问层GA_JYYXX_BAJG_DAL
     /// </summary>
     public class GA_JYYXX_BAJG_DAL
     {
         public GA_JYYXX_BAJG_DAL()
         {
         }


         /// <summary>
         /// 得到最大ID
         /// </summary>
         public int GetMax_ID(string p_strWhere)
         {
             int intResult = 0;
             string strSql = "select max(ID) as m from GA_JYYXX_BAJG";

             if(p_strWhere.Trim().Length > 0)
             {
                 strSql += " where " + p_strWhere;
             }

             DataTable dtTemp = new DataTable();
             DbHelper.GetTable(strSql, ref dtTemp);

             if(dtTemp.Rows.Count>0)
             {
                 if(dtTemp.Rows[0]["m"].ToString().Length>0)
                 {
                     intResult = dtTemp.Rows[0]["m"] == DBNull.Value ? 0 : Convert.ToInt32(dtTemp.Rows[0]["m"]);
                 }
             }

             dtTemp.Dispose();

             return intResult + 1;

          }

          /// <summary>
          /// 得到最大ID
          /// </summary>
          public int GetMax_ID()
          {
              return GetMax_ID("");
          }


          /// <summary>
          /// 判断数据是否存在
          /// </summary>
          public bool Exists(int intID)
          {
               bool bolResult = false;


               string strSql = "";
               strSql += "select count(1) as c from GA_JYYXX_BAJG";
               strSql += " where ";
               strSql += " ID='"+ intID +"'";

               DataTable dtTemp = new DataTable();
               DbHelper.GetTable(strSql, ref dtTemp);

               if (dtTemp.Rows.Count > 0)
               {
                   bolResult = Convert.ToInt32(dtTemp.Rows[0]["c"]) > 0;
               }

               dtTemp.Dispose();

               return bolResult;

          }

          /// <summary>
          /// 获取数据总记录数
          /// </summary>
          public int GetRecordCount(string p_strWhere)
          {
              int intResult=0;

              string strSql = "";
              strSql += "select count(1) as c from GA_JYYXX_BAJG";
              if(p_strWhere.Trim().Length > 0)
              {
                 strSql += " where " + p_strWhere;
              }

              DataTable dtTemp = new DataTable();
              DbHelper.GetTable(strSql, ref dtTemp);

              if(dtTemp.Rows.Count>0)
              {
                  intResult=Convert.ToInt32(dtTemp.Rows[0]["c"]);
              }

              dtTemp.Dispose();

              return intResult;
          }

          /// <summary>
          /// 获取数据总记录数
          /// </summary>
          public int GetRecordCount()
          {
              return GetRecordCount("");
          }

          /// <summary>
          /// 获取数据分页总数
           /// </summary>
          public int GetPageCount(string p_strWhere, int p_intPageSize)
          {
              int intResult=0;

              if(p_intPageSize > 0)
              {
                  int intRecordCount = GetRecordCount(p_strWhere);
                  intResult = Convert.ToInt32(Math.Truncate(Convert.ToDecimal(intRecordCount) / Convert.ToDecimal(p_intPageSize)));
                  if (intRecordCount > (intResult * p_intPageSize))
                  {
                       intResult++;
                  }
              }

              if(intResult == 0)
              {
                   intResult++;
              }
              return intResult;
           }

          /// <summary>
          /// 获取数据分页总数
          /// </summary>
          public int GetPageCount(int p_intPageSize)
          {
              return GetPageCount("", p_intPageSize);
          }

          /// <summary>
          /// 添加一条数据 SQL
          /// </summary>
          public string InsertSQL(GA_JYYXX_BAJG model)
          {
              string strFieldSQL = "";
              string strValueSQL = "";

              if(model.Changed("babh") == true && model.babh != null)
              {
                   strFieldSQL += ",babh";
                   strValueSQL += ",'" + model.babh.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("jyxtmc") == true && model.jyxtmc != null)
              {
                   strFieldSQL += ",jyxtmc";
                   strValueSQL += ",'" + model.jyxtmc.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("jyxtsm") == true && model.jyxtsm != null)
              {
                   strFieldSQL += ",jyxtsm";
                   strValueSQL += ",'" + model.jyxtsm.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("bbbh") == true && model.bbbh != null)
              {
                   strFieldSQL += ",bbbh";
                   strValueSQL += ",'" + model.bbbh.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("kfdw") == true && model.kfdw != null)
              {
                   strFieldSQL += ",kfdw";
                   strValueSQL += ",'" + model.kfdw.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("sjkbb") == true && model.sjkbb != null)
              {
                   strFieldSQL += ",sjkbb";
                   strValueSQL += ",'" + model.sjkbb.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("xtjgms") == true && model.xtjgms != null)
              {
                   strFieldSQL += ",xtjgms";
                   strValueSQL += ",'" + model.xtjgms.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("jczbh") == true && model.jczbh != null)
              {
                   strFieldSQL += ",jczbh";
                   strValueSQL += ",'" + model.jczbh.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("jcxxh") == true && model.jcxxh != null)
              {
                   strFieldSQL += ",jcxxh";
                   strValueSQL += ",'" + model.jcxxh.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("jcsj") == true && model.jcsj != null)
              {
                   strFieldSQL += ",jcsj";
                   strValueSQL += ",'" + model.jcsj.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("yssj") == true && model.yssj != null)
              {
                   strFieldSQL += ",yssj";
                   strValueSQL += ",'" + model.yssj.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("syzt") == true && model.syzt != null)
              {
                   strFieldSQL += ",syzt";
                   strValueSQL += ",'" + model.syzt.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("ztyy") == true && model.ztyy != null)
              {
                   strFieldSQL += ",ztyy";
                   strValueSQL += ",'" + model.ztyy.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("jbr") == true && model.jbr != null)
              {
                   strFieldSQL += ",jbr";
                   strValueSQL += ",'" + model.jbr.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("shbj") == true && model.shbj != null)
              {
                   strFieldSQL += ",shbj";
                   strValueSQL += ",'" + model.shbj.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("shyj") == true && model.shyj != null)
              {
                   strFieldSQL += ",shyj";
                   strValueSQL += ",'" + model.shyj.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("shr") == true && model.shr != null)
              {
                   strFieldSQL += ",shr";
                   strValueSQL += ",'" + model.shr.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("shsj") == true && model.shsj != null)
              {
                   strFieldSQL += ",shsj";
                   strValueSQL += ",'" + model.shsj.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("fzjg") == true && model.fzjg != null)
              {
                   strFieldSQL += ",fzjg";
                   strValueSQL += ",'" + model.fzjg.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("glbm") == true && model.glbm != null)
              {
                   strFieldSQL += ",glbm";
                   strValueSQL += ",'" + model.glbm.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("gxsj") == true && model.gxsj != null)
              {
                   strFieldSQL += ",gxsj";
                   strValueSQL += ",'" + model.gxsj.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("syglbm") == true && model.syglbm != null)
              {
                   strFieldSQL += ",syglbm";
                   strValueSQL += ",'" + model.syglbm.ToString().Replace("'","''") + "'";
              }

              string strSql = "";
              strSql += "insert into GA_JYYXX_BAJG";
              strSql += "(";
              strSql += strFieldSQL.Substring(1);
              strSql += ")";
              strSql += " values";
              strSql += "(";
              strSql += strValueSQL.Substring(1);
              strSql += ")";

              return strSql;
          }

          /// <summary>
          /// 添加一条数据
          /// </summary>
          public bool Insert(GA_JYYXX_BAJG model)
          {
              return DbHelper.ExecuteSql(InsertSQL(model));
          }

          /// <summary>
          /// 修改一条数据 SQL
          /// </summary>
          public string UpdateSQL(GA_JYYXX_BAJG model,int intID)
          {
              string strUpdateSQL = "";

              if(model.Changed("babh") == true && model.babh != null)
              {
                  strUpdateSQL += ",babh='" + model.babh.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("jyxtmc") == true && model.jyxtmc != null)
              {
                  strUpdateSQL += ",jyxtmc='" + model.jyxtmc.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("jyxtsm") == true && model.jyxtsm != null)
              {
                  strUpdateSQL += ",jyxtsm='" + model.jyxtsm.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("bbbh") == true && model.bbbh != null)
              {
                  strUpdateSQL += ",bbbh='" + model.bbbh.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("kfdw") == true && model.kfdw != null)
              {
                  strUpdateSQL += ",kfdw='" + model.kfdw.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("sjkbb") == true && model.sjkbb != null)
              {
                  strUpdateSQL += ",sjkbb='" + model.sjkbb.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("xtjgms") == true && model.xtjgms != null)
              {
                  strUpdateSQL += ",xtjgms='" + model.xtjgms.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("jczbh") == true && model.jczbh != null)
              {
                  strUpdateSQL += ",jczbh='" + model.jczbh.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("jcxxh") == true && model.jcxxh != null)
              {
                  strUpdateSQL += ",jcxxh='" + model.jcxxh.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("jcsj") == true && model.jcsj != null)
              {
                  strUpdateSQL += ",jcsj='" + model.jcsj.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("yssj") == true && model.yssj != null)
              {
                  strUpdateSQL += ",yssj='" + model.yssj.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("syzt") == true && model.syzt != null)
              {
                  strUpdateSQL += ",syzt='" + model.syzt.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("ztyy") == true && model.ztyy != null)
              {
                  strUpdateSQL += ",ztyy='" + model.ztyy.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("jbr") == true && model.jbr != null)
              {
                  strUpdateSQL += ",jbr='" + model.jbr.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("shbj") == true && model.shbj != null)
              {
                  strUpdateSQL += ",shbj='" + model.shbj.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("shyj") == true && model.shyj != null)
              {
                  strUpdateSQL += ",shyj='" + model.shyj.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("shr") == true && model.shr != null)
              {
                  strUpdateSQL += ",shr='" + model.shr.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("shsj") == true && model.shsj != null)
              {
                  strUpdateSQL += ",shsj='" + model.shsj.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("fzjg") == true && model.fzjg != null)
              {
                  strUpdateSQL += ",fzjg='" + model.fzjg.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("glbm") == true && model.glbm != null)
              {
                  strUpdateSQL += ",glbm='" + model.glbm.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("gxsj") == true && model.gxsj != null)
              {
                  strUpdateSQL += ",gxsj='" + model.gxsj.ToString().Replace("'","''") + "'";
              }

              if(model.Changed("syglbm") == true && model.syglbm != null)
              {
                  strUpdateSQL += ",syglbm='" + model.syglbm.ToString().Replace("'","''") + "'";
              }

               string strSql = "";
               strSql += "update GA_JYYXX_BAJG set ";
               strSql += strUpdateSQL.Substring(1);
               strSql += " where ";
               strSql += " ID="+ intID +"";

               return strSql;
          }

          /// <summary>
          /// 修改一条数据
          /// </summary>
          public bool Update(GA_JYYXX_BAJG model, int intID)
          {
              return DbHelper.ExecuteSql(UpdateSQL(model, intID));
          }

          /// <summary>
          /// 修改一个集合 SQL
          /// </summary>
           public string UpdateRangeSQL(GA_JYYXX_BAJG model, string p_strWhere)
          {
               string strUpdateSQL = "";

               if(model.Changed("babh") == true && model.babh != null)
               {
                  strUpdateSQL += ",babh='" + model.babh.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("jyxtmc") == true && model.jyxtmc != null)
               {
                  strUpdateSQL += ",jyxtmc='" + model.jyxtmc.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("jyxtsm") == true && model.jyxtsm != null)
               {
                  strUpdateSQL += ",jyxtsm='" + model.jyxtsm.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("bbbh") == true && model.bbbh != null)
               {
                  strUpdateSQL += ",bbbh='" + model.bbbh.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("kfdw") == true && model.kfdw != null)
               {
                  strUpdateSQL += ",kfdw='" + model.kfdw.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("sjkbb") == true && model.sjkbb != null)
               {
                  strUpdateSQL += ",sjkbb='" + model.sjkbb.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("xtjgms") == true && model.xtjgms != null)
               {
                  strUpdateSQL += ",xtjgms='" + model.xtjgms.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("jczbh") == true && model.jczbh != null)
               {
                  strUpdateSQL += ",jczbh='" + model.jczbh.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("jcxxh") == true && model.jcxxh != null)
               {
                  strUpdateSQL += ",jcxxh='" + model.jcxxh.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("jcsj") == true && model.jcsj != null)
               {
                  strUpdateSQL += ",jcsj='" + model.jcsj.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("yssj") == true && model.yssj != null)
               {
                  strUpdateSQL += ",yssj='" + model.yssj.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("syzt") == true && model.syzt != null)
               {
                  strUpdateSQL += ",syzt='" + model.syzt.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("ztyy") == true && model.ztyy != null)
               {
                  strUpdateSQL += ",ztyy='" + model.ztyy.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("jbr") == true && model.jbr != null)
               {
                  strUpdateSQL += ",jbr='" + model.jbr.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("shbj") == true && model.shbj != null)
               {
                  strUpdateSQL += ",shbj='" + model.shbj.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("shyj") == true && model.shyj != null)
               {
                  strUpdateSQL += ",shyj='" + model.shyj.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("shr") == true && model.shr != null)
               {
                  strUpdateSQL += ",shr='" + model.shr.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("shsj") == true && model.shsj != null)
               {
                  strUpdateSQL += ",shsj='" + model.shsj.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("fzjg") == true && model.fzjg != null)
               {
                  strUpdateSQL += ",fzjg='" + model.fzjg.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("glbm") == true && model.glbm != null)
               {
                  strUpdateSQL += ",glbm='" + model.glbm.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("gxsj") == true && model.gxsj != null)
               {
                  strUpdateSQL += ",gxsj='" + model.gxsj.ToString().Replace("'","''") + "'";
               }

               if(model.Changed("syglbm") == true && model.syglbm != null)
               {
                  strUpdateSQL += ",syglbm='" + model.syglbm.ToString().Replace("'","''") + "'";
               }

              string strSql = "";
              strSql += "update GA_JYYXX_BAJG set ";
              strSql += strUpdateSQL.Substring(1);
              strSql += " where " + p_strWhere;

              return strSql;
          }

          /// <summary>
          /// 修改一个集合
          /// </summary>
          public bool UpdateRange(GA_JYYXX_BAJG model, string p_strWhere)
          {
              return DbHelper.ExecuteSql(UpdateRangeSQL(model, p_strWhere));
          }

          /// <summary>
          /// 修改全部数据 SQL
          /// </summary>
          public string UpdateAllSQL(GA_JYYXX_BAJG model)
          {
              string strUpdateSQL = "";

                  strUpdateSQL += ",babh='" + model.babh.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",jyxtmc='" + model.jyxtmc.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",jyxtsm='" + model.jyxtsm.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",bbbh='" + model.bbbh.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",kfdw='" + model.kfdw.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",sjkbb='" + model.sjkbb.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",xtjgms='" + model.xtjgms.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",jczbh='" + model.jczbh.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",jcxxh='" + model.jcxxh.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",jcsj='" + model.jcsj.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",yssj='" + model.yssj.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",syzt='" + model.syzt.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",ztyy='" + model.ztyy.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",jbr='" + model.jbr.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",shbj='" + model.shbj.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",shyj='" + model.shyj.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",shr='" + model.shr.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",shsj='" + model.shsj.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",fzjg='" + model.fzjg.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",glbm='" + model.glbm.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",gxsj='" + model.gxsj.ToString().Replace("'","''") + "'";
                  strUpdateSQL += ",syglbm='" + model.syglbm.ToString().Replace("'","''") + "'";


               string strSql = "";
               strSql += "update GA_JYYXX_BAJG set ";
               strSql += strUpdateSQL.Substring(1);

               return strSql;

          }

          /// <summary>
          /// 修改全部数据
          /// </summary>
          public bool UpdateAll(GA_JYYXX_BAJG model)
          {
              return DbHelper.ExecuteSql(UpdateAllSQL(model));
          }

          /// <summary>
          /// 删除一条数据 SQL
          /// </summary>
          public string DeleteSQL(int intID)
          {
              string strSql = "";
              strSql += "delete from GA_JYYXX_BAJG";
              strSql += " where ";
               strSql += " ID="+ intID +"";

              return strSql;

          }

          /// <summary>
          /// 删除一条数据
          /// </summary>
          public bool Delete(int intID)
          {
              return DbHelper.ExecuteSql(DeleteSQL(intID));
          }

          /// <summary>
          /// 删除一个集合 SQL
          /// </summary>
          public string DeleteRangeSQL(string p_strWhere)
          {
              string strSql = "";
              strSql += "delete from GA_JYYXX_BAJG";
              strSql += " where " + p_strWhere;

              return strSql;
           }

          /// <summary>
          /// 删除一个集合
          /// </summary>
          public bool DeleteRange(string p_strWhere)
          {
              return DbHelper.ExecuteSql(DeleteRangeSQL(p_strWhere));
          }

          /// <summary>
          /// 删除全部 SQL
          /// </summary>
          public string DeleteAllSQL()
          {
              string strSql = "";
              strSql += "delete from GA_JYYXX_BAJG";

              return strSql;
           }

         /// <summary>
         /// 删除全部
         /// </summary>
         public bool DeleteAll()
         {
             return DbHelper.ExecuteSql(DeleteAllSQL());
         }

          /// <summary>
         /// 得到一个对象实体
         /// </summary>
         public GA_JYYXX_BAJG GetModel(int intID)
         {
             string strSql = "";
             strSql += "select * from GA_JYYXX_BAJG";
             strSql += " where ";
               strSql += " ID="+ intID +"";

             DataTable dtTemp = new DataTable();
             DbHelper.GetTable(strSql, ref dtTemp);

             GA_JYYXX_BAJG model = new GA_JYYXX_BAJG();

             if(dtTemp.Rows.Count>0)
             {
                 model = new GA_JYYXX_BAJG();

                 model.ID = dtTemp.Rows[0]["ID"] == DBNull.Value ? 0 : Convert.ToInt32(dtTemp.Rows[0]["ID"]);
                 model.babh = dtTemp.Rows[0]["babh"] == DBNull.Value ? "" : dtTemp.Rows[0]["babh"].ToString();
                 model.jyxtmc = dtTemp.Rows[0]["jyxtmc"] == DBNull.Value ? "" : dtTemp.Rows[0]["jyxtmc"].ToString();
                 model.jyxtsm = dtTemp.Rows[0]["jyxtsm"] == DBNull.Value ? "" : dtTemp.Rows[0]["jyxtsm"].ToString();
                 model.bbbh = dtTemp.Rows[0]["bbbh"] == DBNull.Value ? "" : dtTemp.Rows[0]["bbbh"].ToString();
                 model.kfdw = dtTemp.Rows[0]["kfdw"] == DBNull.Value ? "" : dtTemp.Rows[0]["kfdw"].ToString();
                 model.sjkbb = dtTemp.Rows[0]["sjkbb"] == DBNull.Value ? "" : dtTemp.Rows[0]["sjkbb"].ToString();
                 model.xtjgms = dtTemp.Rows[0]["xtjgms"] == DBNull.Value ? "" : dtTemp.Rows[0]["xtjgms"].ToString();
                 model.jczbh = dtTemp.Rows[0]["jczbh"] == DBNull.Value ? "" : dtTemp.Rows[0]["jczbh"].ToString();
                 model.jcxxh = dtTemp.Rows[0]["jcxxh"] == DBNull.Value ? "" : dtTemp.Rows[0]["jcxxh"].ToString();
                 model.jcsj = dtTemp.Rows[0]["jcsj"] == DBNull.Value ? "" : dtTemp.Rows[0]["jcsj"].ToString();
                 model.yssj = dtTemp.Rows[0]["yssj"] == DBNull.Value ? "" : dtTemp.Rows[0]["yssj"].ToString();
                 model.syzt = dtTemp.Rows[0]["syzt"] == DBNull.Value ? "" : dtTemp.Rows[0]["syzt"].ToString();
                 model.ztyy = dtTemp.Rows[0]["ztyy"] == DBNull.Value ? "" : dtTemp.Rows[0]["ztyy"].ToString();
                 model.jbr = dtTemp.Rows[0]["jbr"] == DBNull.Value ? "" : dtTemp.Rows[0]["jbr"].ToString();
                 model.shbj = dtTemp.Rows[0]["shbj"] == DBNull.Value ? "" : dtTemp.Rows[0]["shbj"].ToString();
                 model.shyj = dtTemp.Rows[0]["shyj"] == DBNull.Value ? "" : dtTemp.Rows[0]["shyj"].ToString();
                 model.shr = dtTemp.Rows[0]["shr"] == DBNull.Value ? "" : dtTemp.Rows[0]["shr"].ToString();
                 model.shsj = dtTemp.Rows[0]["shsj"] == DBNull.Value ? "" : dtTemp.Rows[0]["shsj"].ToString();
                 model.fzjg = dtTemp.Rows[0]["fzjg"] == DBNull.Value ? "" : dtTemp.Rows[0]["fzjg"].ToString();
                 model.glbm = dtTemp.Rows[0]["glbm"] == DBNull.Value ? "" : dtTemp.Rows[0]["glbm"].ToString();
                 model.gxsj = dtTemp.Rows[0]["gxsj"] == DBNull.Value ? "" : dtTemp.Rows[0]["gxsj"].ToString();
                 model.syglbm = dtTemp.Rows[0]["syglbm"] == DBNull.Value ? "" : dtTemp.Rows[0]["syglbm"].ToString();
             }

             dtTemp.Dispose();

             return model;
         }

         /// <summary>
         /// 得到一个对象实体
         /// </summary>
         public void GetModel(ref DataTable p_dtData, int intID)
         {
             p_dtData.Clear();

             string strSql = "";
             strSql += "select * from GA_JYYXX_BAJG";
             strSql += " where ";
               strSql += " ID="+ intID +"";

              DbHelper.GetTable(strSql, ref p_dtData);
         }

      /// <summary>
      /// 得到对象集合
      /// </summary>
      public GA_JYYXX_BAJG[] GetModelList(string p_strWhere, string p_strOrder, int p_intPageNumber, int p_intPageSize)
      {
          int m_intPageNumber = p_intPageNumber;
          int m_intPageCount = GetPageCount(p_strWhere, p_intPageSize);

          if((m_intPageNumber < 1) || (m_intPageNumber == 0))
          {
               m_intPageNumber = 1;
          }

          if(m_intPageNumber == -1)
          {
               m_intPageNumber = m_intPageCount;
          }

          if(m_intPageNumber > m_intPageCount)
          {
               m_intPageNumber = m_intPageCount;
          }

          string strSql = "";
          strSql += "select * from GA_JYYXX_BAJG";
          if(p_strWhere.Trim().Length > 0)
          {
               strSql += " where " + p_strWhere;
          }
          if(p_strOrder.Trim().Length > 0)
          {
               strSql += " order by " + p_strOrder;
          }

          DataTable dtTemp = new DataTable();

          if(p_intPageSize > 0)
          {
               DbHelper.GetTable(strSql, ref dtTemp, (m_intPageNumber-1)*p_intPageSize, p_intPageSize);
          }
          else
          {
               DbHelper.GetTable(strSql, ref dtTemp);
          }

          GA_JYYXX_BAJG[] arrModel=new GA_JYYXX_BAJG[dtTemp.Rows.Count];

          for(int N=0;N<dtTemp.Rows.Count;N++)
          {
               arrModel[N] = new GA_JYYXX_BAJG();

                 arrModel[N].ID = dtTemp.Rows[N]["ID"] == DBNull.Value ? 0 : Convert.ToInt32(dtTemp.Rows[N]["ID"]);
                 arrModel[N].babh = dtTemp.Rows[N]["babh"] == DBNull.Value ? "" : dtTemp.Rows[N]["babh"].ToString();
                 arrModel[N].jyxtmc = dtTemp.Rows[N]["jyxtmc"] == DBNull.Value ? "" : dtTemp.Rows[N]["jyxtmc"].ToString();
                 arrModel[N].jyxtsm = dtTemp.Rows[N]["jyxtsm"] == DBNull.Value ? "" : dtTemp.Rows[N]["jyxtsm"].ToString();
                 arrModel[N].bbbh = dtTemp.Rows[N]["bbbh"] == DBNull.Value ? "" : dtTemp.Rows[N]["bbbh"].ToString();
                 arrModel[N].kfdw = dtTemp.Rows[N]["kfdw"] == DBNull.Value ? "" : dtTemp.Rows[N]["kfdw"].ToString();
                 arrModel[N].sjkbb = dtTemp.Rows[N]["sjkbb"] == DBNull.Value ? "" : dtTemp.Rows[N]["sjkbb"].ToString();
                 arrModel[N].xtjgms = dtTemp.Rows[N]["xtjgms"] == DBNull.Value ? "" : dtTemp.Rows[N]["xtjgms"].ToString();
                 arrModel[N].jczbh = dtTemp.Rows[N]["jczbh"] == DBNull.Value ? "" : dtTemp.Rows[N]["jczbh"].ToString();
                 arrModel[N].jcxxh = dtTemp.Rows[N]["jcxxh"] == DBNull.Value ? "" : dtTemp.Rows[N]["jcxxh"].ToString();
                 arrModel[N].jcsj = dtTemp.Rows[N]["jcsj"] == DBNull.Value ? "" : dtTemp.Rows[N]["jcsj"].ToString();
                 arrModel[N].yssj = dtTemp.Rows[N]["yssj"] == DBNull.Value ? "" : dtTemp.Rows[N]["yssj"].ToString();
                 arrModel[N].syzt = dtTemp.Rows[N]["syzt"] == DBNull.Value ? "" : dtTemp.Rows[N]["syzt"].ToString();
                 arrModel[N].ztyy = dtTemp.Rows[N]["ztyy"] == DBNull.Value ? "" : dtTemp.Rows[N]["ztyy"].ToString();
                 arrModel[N].jbr = dtTemp.Rows[N]["jbr"] == DBNull.Value ? "" : dtTemp.Rows[N]["jbr"].ToString();
                 arrModel[N].shbj = dtTemp.Rows[N]["shbj"] == DBNull.Value ? "" : dtTemp.Rows[N]["shbj"].ToString();
                 arrModel[N].shyj = dtTemp.Rows[N]["shyj"] == DBNull.Value ? "" : dtTemp.Rows[N]["shyj"].ToString();
                 arrModel[N].shr = dtTemp.Rows[N]["shr"] == DBNull.Value ? "" : dtTemp.Rows[N]["shr"].ToString();
                 arrModel[N].shsj = dtTemp.Rows[N]["shsj"] == DBNull.Value ? "" : dtTemp.Rows[N]["shsj"].ToString();
                 arrModel[N].fzjg = dtTemp.Rows[N]["fzjg"] == DBNull.Value ? "" : dtTemp.Rows[N]["fzjg"].ToString();
                 arrModel[N].glbm = dtTemp.Rows[N]["glbm"] == DBNull.Value ? "" : dtTemp.Rows[N]["glbm"].ToString();
                 arrModel[N].gxsj = dtTemp.Rows[N]["gxsj"] == DBNull.Value ? "" : dtTemp.Rows[N]["gxsj"].ToString();
                 arrModel[N].syglbm = dtTemp.Rows[N]["syglbm"] == DBNull.Value ? "" : dtTemp.Rows[N]["syglbm"].ToString();
          }

          dtTemp.Dispose();

          return arrModel;
      }

      /// <summary>
      /// 得到对象集合
      /// </summary>
      public GA_JYYXX_BAJG[] GetModelList(string p_strWhere)
      {
          return GetModelList(p_strWhere, "", -1, -1);
      }

      /// <summary>
      /// 得到对象集合
      /// </summary>
      public GA_JYYXX_BAJG[] GetModelList(string p_strWhere, string p_strOrder)
      {
          return GetModelList(p_strWhere, p_strOrder, -1, -1);
      }

      /// <summary>
      /// 得到对象集合
      /// </summary>
      public GA_JYYXX_BAJG[] GetModelList(int p_intPageNumber, int p_intPageSize)
      {
          return GetModelList("", "", p_intPageNumber, p_intPageSize);
      }

      /// <summary>
      /// 得到对象集合
      /// </summary>
      public GA_JYYXX_BAJG[] GetModelList(string p_strWhere, int p_intPageNumber, int p_intPageSize)
      {
          return GetModelList(p_strWhere, "", p_intPageNumber, p_intPageSize);
      }

      /// <summary>
      /// 得到对象集合
      /// </summary>
      public GA_JYYXX_BAJG[] GetModelList()
      {
          return GetModelList("", "", -1, -1);
      }

      /// <summary>
      /// 得到对象集合
      /// </summary>
      public void GetModelList(ref DataTable p_dtData, string p_strWhere, string p_strOrder, int p_intPageNumber, int p_intPageSize)
      {
          p_dtData.Clear();

          int m_intPageNumber = p_intPageNumber;
          int m_intPageCount = GetPageCount(p_strWhere, p_intPageSize);

          if((m_intPageNumber < 1) || (m_intPageNumber == 0))
          {
              m_intPageNumber = 1;
          }

          if(m_intPageNumber == -1)
          {
              m_intPageNumber = m_intPageCount;
          }

          if(m_intPageNumber > m_intPageCount)
          {
              m_intPageNumber = m_intPageCount;
          }

          string strSql = "";
          strSql += "select * from GA_JYYXX_BAJG";
          if(p_strWhere.Trim().Length > 0)
          {
              strSql += " where " + p_strWhere;
          }
          if(p_strOrder.Trim().Length > 0)
          {
              strSql += " order by " + p_strOrder;
          }

          if(p_intPageSize > 0)
          {
              DbHelper.GetTable(strSql, ref p_dtData, (m_intPageNumber-1)*p_intPageSize, p_intPageSize);
          }
          else
          {
              DbHelper.GetTable(strSql, ref p_dtData);
          }
       }

       /// <summary>
       /// 得到对象集合
       /// </summary>
       public void GetModelList(ref DataTable p_dtData, string p_strWhere)
       {
           GetModelList(ref p_dtData, p_strWhere, "", -1, -1);
       }

       /// <summary>
       /// 得到对象集合
       /// </summary>
       public void GetModelList(ref DataTable p_dtData, string p_strWhere, string p_strOrder)
       {
           GetModelList(ref p_dtData, p_strWhere, p_strOrder, -1, -1);
       }

       /// <summary>
       /// 得到对象集合
       /// </summary>
       public void GetModelList(ref DataTable p_dtData, int p_intPageNumber, int p_intPageSize)
       {
           GetModelList(ref p_dtData, "", "", p_intPageNumber, p_intPageSize);
       }

       /// <summary>
       /// 得到对象集合
       /// </summary>
       public void GetModelList(ref DataTable p_dtData, string p_strWhere, int p_intPageNumber, int p_intPageSize)
       {
           GetModelList(ref p_dtData, p_strWhere, "", p_intPageNumber, p_intPageSize);
       }
       /// <summary>
       /// 得到对象集合
       /// </summary>
       public void GetModelList(ref DataTable p_dtData)
       {
           GetModelList(ref p_dtData, "", "", -1, -1);
       }
   }
}
